package cn.tedu.zhxy.service.impl;

import cn.tedu.zhxy.entity.Grade;
import cn.tedu.zhxy.mapper.GradeMapper;
import cn.tedu.zhxy.service.GradeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-07-20
 */
@Service
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade> implements GradeService {

    @Override
    public IPage<Grade> getGradsByOpr(Page<Grade> pageParam, String gradeName) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (!StringUtils.isEmpty(gradeName)){
            queryWrapper.eq("name",gradeName);
            Page<Grade> page = baseMapper.selectPage(pageParam, queryWrapper);
            return page;
        }else {
            Page<Grade> page = baseMapper.selectPage(pageParam, null);
            return  page;
        }

    }
}
